﻿//打开字滑入效果
window.onload = function(){
	$(".connect p").eq(0).animate({"left":"0%"}, 600);
	$(".connect p").eq(1).animate({"left":"0%"}, 400);
};
//jquery.validate表单验证
$(document).ready(function(){
	//登陆表单验证
	$("#loginForm").validate({
	    rules: {
	        Account: {
	            required: true,//必填
	            minlength: 3, //最少6个字符
	            maxlength: 32,//最多20个字符
	        },   
			Password:{
				required:true,
				minlength:6, 
				maxlength:32,
			},
		},
		//错误信息提示
	    messages: {
	        Account: {
	            required: "必须填写账号",
	            minlength: "账号至少为3个字符",
	            maxlength: "账号至多为32个字符",
	            remote: "账号已存在",
	        },		   
			Password:{
				required:"必须填写密码",
				minlength:"密码至少为6个字符",
				maxlength:"密码至多为32个字符",
			},
		},
	    submitHandler: function (form) {
	        $.post("/Manage/Login/Login", $(form).serialize(), function (rv) {
	            if (rv.State) {
	                return window.location.href = "/Manage/Home/Index";	               
	            } else {
	                Alert(rv.Message,true);
	            }
	        });
	    }
	});
	
	//添加自定义验证规则
	jQuery.validator.addMethod("phone_number", function(value, element) { 
		var length = value.length;
		var MobilePhone = /^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$/;
		return this.optional(element) || (length == 11 && MobilePhone.test(value));
	}, "手机号码格式错误"); 
});
